package a51qindian.com.comprehensive.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.li.widget.DoubleTextView;

import java.util.List;

import a51qindian.com.comprehensive.R;
import a51qindian.com.comprehensive.model.Withdraw;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: Li
 * Date: 2017/9/13 0013
 * Description: 提现记录
 */

public class CrashDetailAdapter extends RecyclerView.Adapter<CrashDetailAdapter.CrashDetailHolder> {


    private LayoutInflater mInflater;

    public CrashDetailAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }

    private List<Withdraw> mWithdrawList;

    @Override
    public CrashDetailHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_crash_detail, parent, false);
        return new CrashDetailHolder(view);
    }

    @Override
    public void onBindViewHolder(CrashDetailHolder holder, int position) {
        Withdraw withdraw=mWithdrawList.get(position);
        holder.mTxtCrashType.setTxtRight(withdraw.getBank_name());
        holder.mTxtCrashMan.setTxtRight(withdraw.getAccount_name());
        holder.mTxtCrashNum.setTxtRight(String.valueOf(withdraw.getMoney()+"元"));
        holder.mTxtCrashAccount.setTxtRight(withdraw.getAccount_bank());
        holder.mTxtCrashState.setTxtRight(getState(withdraw.getStatus()));
        holder.mTxtCrashDate.setTxtRight(withdraw.getAdd_time());
        holder.mTxtCrashRemark.setTxtRight(withdraw.getRemark());
    }

    @Override
    public int getItemCount() {
        return mWithdrawList == null ? 0 : mWithdrawList.size();
    }

    public void setWithdrawList(List<Withdraw> withdrawList) {
        mWithdrawList = withdrawList;
        notifyDataSetChanged();
    }

    private String getState(String state){
        String s="";
        switch (state) {
            case "0":
                s="申请中";
                break;
            case "1":
                s="申请成功";
                break;
            case "2":
                s="申请失败";
                break;
        }
        return s;
    }
    static class CrashDetailHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_crash_type)
        DoubleTextView mTxtCrashType;
        @BindView(R.id.txt_crash_man)
        DoubleTextView mTxtCrashMan;
        @BindView(R.id.txt_crash_num)
        DoubleTextView mTxtCrashNum;
        @BindView(R.id.txt_crash_account)
        DoubleTextView mTxtCrashAccount;
        @BindView(R.id.txt_crash_state)
        DoubleTextView mTxtCrashState;
        @BindView(R.id.txt_crash_date)
        DoubleTextView mTxtCrashDate;
        @BindView(R.id.txt_crash_remark)
        DoubleTextView mTxtCrashRemark;
        public CrashDetailHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
